/*
 * Copyright © 2023 广州宏天软件股份有限公司 hotent
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hotent.project.app.conf;

import com.hotent.base.conf.MybatisPlusConfig;
import com.hotent.base.filter.ClobDataResultSetFilter;
import com.hotent.base.interceptor.ResultSetFilter;
import com.hotent.base.interceptor.ResultSetInterceptor;
import com.hotent.base.util.AppUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author: 黎扬贵
 * @description: 覆盖base模块下的拦截器
 * @date: 2023/6/20 下午4:21
 * @version: 1.0
 */
@Configuration
public class InterceptorConfig {

    @Resource(name = "getResultSetInterceptor")
    ResultSetInterceptor resultSetInterceptor;

    /**
     * 返回结果处理拦截器
     * 
     * @return
     */
    @PostConstruct
    public void resetResultSetInterceptor() {
        // clob 数据格式化处理
        ClobDataResultSetFilter clobDataResultSetFilter = new ClobDataResultSetFilter();
        CopyOnWriteArrayList<ResultSetFilter> copyOnWriteArrayList = new CopyOnWriteArrayList<>();
        copyOnWriteArrayList.add(clobDataResultSetFilter);
        resultSetInterceptor.setFilters(copyOnWriteArrayList);
    }
}
